<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <title>MyBlog-Register</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--====== Favicon Icon ======-->
    <link rel="shortcut icon" href="assets/images/favicon.png" type="image/png">
    <!--====== Bootstrap CSS ======-->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <!--====== SignIn CSS ======-->
    <link rel="stylesheet" href="assets/css/register.css">
</head>

<body style="background-color: whitesmoke">
<!--====== 从这里开始 ======-->
<form class="form-signin">
    <div style="text-align: center">
        <img class="mb-4" src="assets/images/signin/blog-icon.png" alt="" width="72" height="72">
    </div>
    <h3 class="mb-3 font-weight-normal" style="text-align: center">注册</h3>
    <input type="text" id="username" class="form-control" placeholder="username" required autofocus>
    <input type="text" id="phone" class="form-control" placeholder="phone" required>
    <input type="email" id="email" class="form-control" placeholder="email" required>
    <input type="number" id="age" class="form-control" placeholder="age" required>
    <input type="password" id="inputPassword" class="form-control" placeholder="password" required>
    <input type="password" id="rePassword" class="form-control" placeholder="repeat password" required>
    <div class="d-block my-3">
        <div class="custom-control custom-radio d-inline">
            <input id="btn_man" name="radiob" type="radio" value="男" class="custom-control-input" checked="checked" required="required">
            <label class="custom-control-label" for="btn_man">男性</label>
        </div>
        <div class="custom-control custom-radio d-inline">
            <input id="btn_woman" name="radiob" type="radio" value="女" class="custom-control-input" required="required">
            <label class="custom-control-label" for="btn_woman">女性</label>
        </div>
    </div>
    <button class="btn btn-lg btn-primary btn-block" type="button" onclick="RegSubmit()">提交注册</button>
    <div style="text-align: center">
        <p class="mt-5 mb-3 text-muted">&copy; 2018-2020</p>
    </div>
</form>

<!--====== 从这里结束 ======-->
<!--====== 自定义代码结束 ======-->


<!--导入所有js文件-->
<!--====== Jquery js ======-->
<script src="assets/js/vendor/jquery-1.12.4.min.js"></script>
<!--====== Bootstrap js ======-->
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/util/HttpUtil.js"></script>
</body>

</html>
<script type="text/javascript">
    function RegSubmit(){
        let username = $("#username").val();
        let phone = $("#phone").val();
        let email = $("#email").val();
        let age = $("#age").val();
        let inputPassword = $("#inputPassword").val();
        let rePassword = $("#rePassword").val();
        if (username=="" || phone=="" || email=="" || age=="" || inputPassword=="" || rePassword==""){
            alert("所有项都不能为空");
            return;
        }
        if (!inputPassword==rePassword){
            alert("两次密码不一致");
            return;
        }
        let sex = $("input[type='radio']:checked").val();
        let  url="register.do";
        let params = {username: username, phone: phone, email: email,
            age: age, password: inputPassword, sex: sex};
        doPost(url,params,function (json) {
            location.href = "http://localhost:8080/blog_view/login.html";
            alert("注册成功，请登录");
        })
    }
</script>